package cn.bitkit.mybatis;

import cn.bitkit.base.constants.DialectType;

/**
 * 
 * @author changbo
 *
 */
public class DialectContext {
	
	private static DialectType defaultDialectType = DialectType.mysql;
	private static final ThreadLocal<DialectType> DIALECT_TYPE = new ThreadLocal<>();

	public static void setDefaultDialectType(DialectType dialectType) {
		DialectContext.defaultDialectType = dialectType;
	}

	public static DialectType getDialectType() {
		if(DIALECT_TYPE.get() == null) {
			return defaultDialectType;
		}
		return DIALECT_TYPE.get();
	}

	public static void setDialectType(DialectType dialectType) {
		DialectContext.DIALECT_TYPE.set(dialectType);
	}

	public static void clear(){
		DialectContext.DIALECT_TYPE.remove();
	}


}
